package com.wangx1n;


import com.wangx1n.bean.Person;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author WangXin
 * @date 2020/12/3 14:04
 */
public class MyTest {
//    bean作用域
    @Test
    public void BeanScopeTest(){
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        Person person1 = context.getBean("person", Person.class);
        Person person2 = context.getBean("person", Person.class);
        //输出地址相同，说明默认创建bean是单例的
        System.out.println(person1);
        System.out.println(person2);

        //通过修改bean的scope属性为prototype，变为了多实例
    }
}
